#include <ocr.h>

using namespace std;

string app_id = "18019635";
string api_key = "ZVEa58G8StIcxF6O4icC1Vt7";
string secret_key = "fU1RPzvNmu2o5OUuLoIfXadlZa2Y8O7f";

int main()
{
    aip::Ocr client(app_id, api_key, secret_key);
    string image;

    //读取图像文件
    aip::get_file_content("demo.jpg", &image);

    map<string, string> options;
    //是否检测多个车牌
    options["multi_detect"] = "true";

    Json::Value result = client.license_plate(image, options);
    //cout << result.toStyledString() << endl;
    if (!result["error_code"].isNull()) {
        cout << result["error_code"] << endl;
        return 1;
    }
    //是否存在多个车牌
    if (result["words_result"].isArray()) {
        //打印所有车牌
        for(unsigned int i = 0; i < result["words_result"].size(); i++) {
            cout << result["words_result"][i]["number"].asString() << endl;
        }
    }
    else {
        cout << result["words_result"]["number"].asString() << endl;
    }

    return 0;
}
